"""
演示异常的捕获语法
"""
# 基本捕获语法
try:
    f = open("D:/abc.txt","r",encoding="UTF-8")
except:
    print("文件不存在，已改为创建模式，你现在可以写入内容")
    f = open("D:/abc.txt","w",encoding="UTF-8")

# # 捕获指定异常
# try:
#     print(name)
# except NameError as e:
#     print(e)

# 捕获多个异常
try:
    1/0
    print(name)
except (NameError,ZeroDivisionError) as e:
    print(e)